Saving files on Android
There are many place where you can store data on an Android device: /mnt/sdcard This is usually the external memory card. You can write there, but the user can read or write your files. Some mobile phone use /mnt/sdcard as internal memory avaliable for all apps, and /mnt/sdcard2 as the external memory card. Both folders are avaliable to read and write to all apps, so they can be used for data exchange. Remember that when you connect you mobile phone to a PC, only the external memory card is visible as an USB memory to the PC. Please note that Google removed the possibility to save on SDcard on Android 4.4, but he added again from Android 5. So if you have Android 4.4 please read Fix Write Capability to external SD Card on Andoid 4.4 (KitKat) specialFolderPath("Documents") Here you can write, but user can't see it. All information here are reserved to your app and other app can't write or read here. If you upgrade your app, the files in this folder are unchanged. specialFolderPath("engine") Here are all the enclosed files of the app. All files choosen in copy files page of the Stand alone application settings are placed here. If you upgrade your app, the files in this folder are changed with the new ones of the new version of your app. Notice that you will have always only read permission on file and folders in this folder. You can't even use open a SQLite database. You need to copy in another location all special file that you need to write. =How Android filesystem works= Android is identical to Linux filesytem (see http://www.tldp.org/LDP/intro-linux/html/sect_03_01.html#AEN2004 ). However Android, in order to preserve mobile phone security, doesn't unpack your app in filesytem, but in a separate virtual folder that seems in the filesystem. For example if you app identifier is "com.yourcompany.myapp", then app will be unpacked in /data/app/com.yourcompany.myapp-'''1'.apk/''; that it's a fake directory that doesn't exist (for security reasons). This directory contains the following subdirectories: * images/ * sounds/ * webkit/ * all other files you copy with the app. See specialfolderpath("engine") above. Don't try to use this position, because if you install a new release of your app, the directory of the unpacked app will change to /data/app/com.yourcompany.myapp-'''2'.apk/''. Every time you install a new version of the app, even if you don't insert a version number, the mobile phone will create a new virtual directory, with a new number, so all data in the previous ones are deleted. Fortunately Android creates also a common virtual directory for all app version that is /data/data/com.yourcompany.myapp/files/. This directory is the specialFolderPath("Documents"). Beware that this virtual folder exists only for the app, so if you remove the app, the folder and its content will be deleted. In the end, an app can write or in specialFolderPath("Documents") or in a SDcard. Some devices have an internal SDcard fixed and a removable SDcard, in this case you have /mnt/sdcard as the internal SDcard and /mnt/sdcard2 as the removable sdcard. Please note of the Android or Linux mounting system: when you remove the sdcard, the /mnt/sdcard directory remains, becomes empty and you can create file and directory, but when you insert again the SDcard, the /mnt/sdcard folder switch to show the content of the SDcard. Remove again the SDcard the old content reappears. This is very confusing for the user, so please avoid to use these effect in your app. Category:Android